﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;

namespace PonGun
{
    public class TitleScreen : Screen
    {
        TimeSpan Duration = new TimeSpan(0, 0, 0, 3, 0);
        TimeSpan Start = TimeSpan.Zero;
        bool JobDone { get { return (Duration - (DateTime.Now.TimeOfDay - Start)) < TimeSpan.Zero; } }

        public TitleScreen(Game1 game, GSM gsm)
            : base(game,gsm)
        {
            HasMouse = false;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (State == ScreenStates.FadedIn)
            {
                if (Start == TimeSpan.Zero)
                    Start = DateTime.Now.TimeOfDay;

                if(JobDone)
                    GSM.NavigateTo("MenuScreen");
            }

            if(Game.thisKB.GetPressedKeys().Length > 0 || Game.thisMS.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                GSM.NavigateTo("MenuScreen");
            
            if (Game.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape))
                Game.Exit();
        }

        public override void CloseDown()
        {
            Start = TimeSpan.Zero;
        }
    }
}
